unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls, Spin, Menus, Mask, ExtCtrls, ImgList, ToolWin,
  ComCtrls, ActnList, jpeg;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    SpinEdit1: TSpinEdit;
    SaveDialog1: TSaveDialog;
    OpenDialog1: TOpenDialog;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    N11: TMenuItem;
    N12: TMenuItem;
    MaskEdit1: TMaskEdit;
    ImageList1: TImageList;
    ControlBar1: TControlBar;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolBar2: TToolBar;
    ToolButton7: TToolButton;
    ToolBar3: TToolBar;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ImageList2: TImageList;
    Panel1: TPanel;
    Image1: TImage;
    ImageList3: TImageList;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    Panel2: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit5: TEdit;
    Shape1: TShape;
    Button5: TButton;
    Image2: TImage;
    PopupMenu1: TPopupMenu;
    N13: TMenuItem;
    N14: TMenuItem;
    N15: TMenuItem;
    N16: TMenuItem;
    N17: TMenuItem;
    N18: TMenuItem;
    N19: TMenuItem;
    N20: TMenuItem;
    N21: TMenuItem;
    PopupMenu2: TPopupMenu;
    N22: TMenuItem;
    N23: TMenuItem;
    N24: TMenuItem;
    N25: TMenuItem;
    MaskEdit3: TMaskEdit;
    MaskEdit2: TMaskEdit;
    Label5: TLabel;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    Image4: TImage;
    Image5: TImage;
    Image3: TImage;
    ColorDialog1: TColorDialog;
    FontDialog1: TFontDialog;
    N26: TMenuItem;
    N27: TMenuItem;
    N28: TMenuItem;
    CheckBox1: TCheckBox;
    N29: TMenuItem;
    ScrollBar1: TScrollBar;
    procedure FormShow(Sender: TObject);
    procedure StringGrid1DblClick(Sender: TObject);
    procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure SpinEdit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    Procedure Raschet(sender: Tobject);
    procedure SaveFale(Sender:Tobject);
    procedure LoadFile(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Delete(Sender:TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure MaskEdit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ToolButton1Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);

    procedure Addsapis(Sender: TObject);
    procedure Sagruska(Sender: TObject;Sx1:integer) ;
    procedure SAve(Sender: TObject;Sx1:integer);    {Сохранение данных}
    procedure DeleteSapis(Sender: TObject);
    procedure PoiskSapis(Sender: TObject; noms: Byte);
    procedure PoiskSApis2(Sender: TObject; Val:string);
    procedure EditSapis(Sender: TObject);
    function Podchet(Val:String):integer;
    procedure SaveNastroi(Sender: TObject);    {Cохранение нестроек}
    procedure LoadNastroi(Sender: TOBject);

    procedure N3Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure Image1Click(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Edit1Click(Sender: TObject);
    procedure Image2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image2MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Panel2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image2Click(Sender: TObject);
    procedure Image3MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image3MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image3MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image4MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image4MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image4MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image5MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Image5MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image5MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image3Click(Sender: TObject);
    procedure Image4Click(Sender: TObject);
    procedure Image5Click(Sender: TObject);
    procedure N25Click(Sender: TObject);
    procedure N8Click(Sender: TObject);
    procedure N23Click(Sender: TObject);
    procedure N24Click(Sender: TObject);
    procedure N22Click(Sender: TObject);
    procedure N15Click(Sender: TObject);
    procedure N14Click(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N19Click(Sender: TObject);
    procedure N18Click(Sender: TObject);
    procedure N17Click(Sender: TObject);
    procedure N20Click(Sender: TObject);
    procedure N12Click(Sender: TObject);
    procedure N21Click(Sender: TObject);
    procedure N11Click(Sender: TObject);
    procedure N10Click(Sender: TObject);
    procedure Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure StringGrid1Click(Sender: TObject);
    procedure FormDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure FormDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure N27Click(Sender: TObject);
    procedure N28Click(Sender: TObject);

  private
    { Private declarations }
  public

  Xc,  Yc:integer;
selsap:integer;

    { Public declarations }
  end;

var
  Form1: TForm1;

  Const nn=50;
  Const tt=50;
  Type
   abonent=record
   Fio : String[30];
   nomer : String[11];
   SMTR : string[10];
   VSum : string[10];
   Active: string[10];
   end;

   Type
   Nastroi=record
   Vkl : String[10];
   ColorForm: TColor;
   FontSize: integer;
   FontColor: TColor;
   FontStyle: TFontStyles;
   Butt1L :integer;
   Butt1T :integer;
   Butt2L :integer;
   Butt2T :integer;
   Butt3L :integer;
   Butt3T :integer;
   end;
Var a : Array [1..nn] of abonent;
  vkl: array[1..100] of string;
ns :Nastroi;

ab:Abonent;
nas:Nastroi;

F,Copf:File of abonent;
FN:File of Nastroi;
n,b:Byte;


implementation


uses UnitEdit, UnitDolg, UnitSprav, UnitZastavka, UnitGrafic, UnitPodwerd;



{$R *.dfm}

{procedure TForm1.Addsapis(Sender: TObject);
begin
Reset(F);
Seek(F,Filesize(F)); {Указатель на конец файла}
{Write(F,K[n]);
CloseFile(F);
end;  }
function TForm1.Podchet(val:string):integer;
var i:integer;
n:Byte;
begin
n:=0;
result:=0;
for i:=1 to Stringgrid1.RowCount-1 do
begin
n:=n+1;
if a[n].Active=val then
begin
result:=result+1;
end;

end;

end;



procedure TForm1.PoiskSApis2(Sender: TObject; val:string);
Var S: String[5]; a:abonent;
begin
AssignFile(F,'abonent');
reset(F);

while not Eof(F) do
  begin
Read(F,a);
if  a.nomer=val then
begin
Dolg.nom:=Filepos(F);
Edit2.Text:=a.Fio;
MaskEdit2.Text:=a.VSum;
MaskEdit3.Text:=a.SMTR;
Edit5.Text:=a.Active;
end;
  end;

closefile(F);

end;


procedure TForm1.EditSapis(Sender: TObject);
var a:abonent;
begin

a.Fio:=Editi.Edit1.Text;
a.nomer:=Editi.MaskEdit3.Text;
a.VSum:=Editi.SpinEdit2.Text;
a.SMTR:=Editi.SpinEdit3.Text;
a.Active:=Editi.ComboBox1.Text;
write(F,a);
closefile(F);


end;


procedure TForm1.PoiskSapis(Sender: TObject; noms: Byte);
Var S: String[5]; a:abonent;
begin
AssignFile(F,'abonent');
reset(F);
Seek(F,noms);
Read(F,a);
Editi.Edit1.Text:=a.Fio;
Editi.MaskEdit3.Text:=a.nomer;
Editi.SpinEdit2.Value:=strtoint(a.VSum);
Editi.SpinEdit3.Value:=strtoint(a.SMTR);
Editi.ComboBox1.Text:=a.Active;
Seek(F,noms);

ab:=a;
end;




Procedure TForm1.DeleteSapis(Sender: TObject);
Var

a:abonent;
chet:integer;
K:1..10000;
c:String;found:boolean;

begin
AssignFile(Copf,'copf');
k:=selsap;
Reset(f);Rewrite(Copf); {позиционирование файлов}
Found:=False;
chet:=0;
While not Eof(F) do begin
Read(F,a); {читаем запись из файла}
If Chet<>K then Begin Write(Copf,a);Chet:=Chet+1;end    {if1}
{если номер записи не k,записываем ее в файл-{копию}
Else
begin   {if1}
found:=true; {запись для удаления найдена}

{Case c of
д','Д','у','У:}
podwerd.ShowModal;
if podwerd.sogl=true then begin k:=10000 end
else     begin Write(Copf,a);k:=10000; end;  {раздумали удалять, }

end;    {if1}

end; {while}

CloseFile(F); CloseFile(Copf); {закрываем файлы }
{ If not Found   }

if k=10000 then begin
Erase(F); Rename(copf,'abonent'); end;

end;


procedure Tform1.SaveNastroi(Sender: TObject);
var i:Byte;
begin

Assignfile(FN,'NAstroiki');
Rewrite(FN);

{b:=b+1;}
i:=1;

if CheckBox1.Checked=True then
begin
ns.Vkl:='Вкл.';
end;
if CheckBox1.Checked=False then
begin
ns.Vkl:='Выкл.';
end;



ns.ColorForm:=form1.Color;

ns.FontSize:=Form1.Font.Size;
ns.FontColor:=Form1.Font.Color;
ns.FontStyle:=Form1.Font.Style;
ns.Butt1L:=Panel3.Left;
ns.Butt1T:=Panel3.Top;
ns.Butt2L:=Panel4.Left;
ns.Butt2T:=Panel4.Top;
ns.Butt3L:=Panel5.Left;
ns.Butt3T:=Panel5.Top;

{ns[b].ColorText:= }

write(FN,ns);
{for i:=1 to n do begin write(F,a[i]); end; }

closefile(FN);

end;



Procedure TForm1.SAve(Sender: TObject;Sx1:integer);
var i:Byte;
begin

case Sx1 of
1:begin
if SaveDialog1.Execute then
begin
Assignfile(F,SaveDialog1.FileName);
end;
 end;
2:begin
Assignfile(F,'abonent');
end;
end;
Rewrite(F);

n:=n+1;

a[n].Fio:=Editi.Edit1.Text;
a[n].nomer:=Editi.MaskEdit3.Text;
a[n].VSum:=Editi.SpinEdit2.Text;
a[n].SMTR:=Editi.SpinEdit3.Text;
a[n].Active:=Editi.ComboBox1.Text;

for i:=1 to n do begin write(F,a[i]); end;

closefile(F);
end;




procedure TForm1.Addsapis(Sender: TObject);
begin
{Assignfile(F,'Abonent');}
Reset(F);
n:=n+1;

a[n].Fio:=Editi.Edit1.Text;
a[n].nomer:=Editi.MaskEdit3.Text;
a[n].VSum:=Editi.SpinEdit2.Text;
a[n].SMTR:=Editi.SpinEdit3.Text;
a[n].Active:=Editi.ComboBox1.Text;

Seek(F,Filesize(F)); {Указатель на конец файла}
Write(F,a[n]);
CloseFile(F);
end;





Procedure TForm1.Sagruska(Sender: TObject;Sx1:integer);
VAr i:byte;
begin

case Sx1 of
1:begin  {1c}
if OpenDialog1.Execute then
begin
AssignFile(F,OpenDialog1.FileName);



end;

end;      {1c}
2:begin    {2c}
if not(FileExists('abonent')) then
begin              {if1}
ShowMessage('Файла данных не существует добавьте первого абонента');
end else begin {if1}

AssignFile(F,'abonent');

Reset(F);
n:=FileSize(f);
stringgrid1.RowCount:=n+1;

For i:=1 to n do
begin
read(f,a[i]);
stringgrid1.Cells[0,i]:=a[i].nomer;
stringgrid1.Cells[1,i]:=a[i].SMTR;
vkl[i]:=a[i].Active;
if (a[i].VSum<>'') and (a[i].SMTR<>'') then
begin
stringgrid1.Cells[2,i]:=inttostr(strtoint(a[i].VSum)-strtoint(a[i].SMTR));
end;
end;
closefile(f);
 {if1}

end;




end;      {2c}

end;      {case}




end;

procedure TForm1.LoadNastroi(Sender: TObject);
VAr i:byte;
begin
if not(FileExists('NAstroiki')) then
begin end else

begin
AssignFile(FN,'NAstroiki');
Reset(FN);
{b:=FileSize(fn);  }
i:=1;

read(FN,ns);

if ns.Vkl='Вкл.' then
begin

{Загрузка цвета}
Form1.CheckBox1.Checked:=true;

Form1.Color:=ns.ColorForm;
Editi.Color:=ns.ColorForm;
Dolg.Color:=ns.ColorForm;
Grafic.Color:=ns.ColorForm;
panel3.Color:=ns.ColorForm;
panel4.Color:=ns.ColorForm;
panel5.Color:=ns.ColorForm;
panel1.color:=ns.ColorForm;


{Загрузка шрифта}
Form1.Font.Size:=ns.FontSize;
Form1.Font.Color:=ns.FontColor;
Form1.Font.Style:=ns.FontStyle;

Editi.Font.Size:=ns.FontSize;
Editi.Font.Color:=ns.FontColor;
Editi.Font.Style:=ns.FontStyle;

Dolg.Font.Size:=ns.FontSize;
Dolg.Font.Color:=ns.FontColor;
Dolg.Font.Style:=ns.FontStyle;

Grafic.Font.Size:=ns.FontSize;
Grafic.Font.Color:=ns.FontColor;
Grafic.Font.Style:=ns.FontStyle;

{Загрузка кнопок}
Panel3.Left:= ns.Butt1L;
Panel3.Top:=ns.Butt1T;
Panel4.Left:=ns.Butt2L;
Panel4.Top:=ns.Butt2T;
Panel5.Left:=ns.Butt3L;
Panel5.Top:=ns.Butt3T;

{Editi.Font:=ns.FontForm;
Dolg.Font:=ns.FontForm;
Grafic.Font:=ns.FontForm;}


end;
closefile(FN);
end;

end;







procedure Tform1.LoadFile(sender:TObject);
var  i,j,h:integer;
F,F1:TExtFile;
s:string;
begin
Assignfile(F,'date\1');
reset(f);


j:=0;
{for j:=1 to stringgrid1.RowCount-1 do
begin  }
while not Eof(f) do begin
j:=j+1;
s:='';
readln(f,s);    {Прочитали строку}
h:=0;
for i:=0 to stringgrid1.ColCount-1 do  {f}
begin

repeat        {r}
h:=h+1;
if s[h]<>'#' then
begin
stringgrid1.Cells[i,j]:=stringgrid1.Cells[i,j]+s[h];
end;

until s[h]='#' {r}


end;       {f}
if not Eof(f) then begin
stringgrid1.RowCount:=stringgrid1.RowCount+1;   end;

end;

closefile(f);
end;










procedure Tform1.SaveFale(sender:Tobject);
var  i,j,h:integer;
F,F1:TextFile;
s:string;
begin

Assignfile(F,'date\1');
rewrite(f);


for j:=1 to stringgrid1.RowCount-1 do
begin
for i:=0 to stringgrid1.ColCount-1 do
begin
write(f,stringgrid1.cells[i,j]);
write(f,'#');
end;
writeln(f,'');
end;
closefile(f);



end;


procedure Tform1.Delete(Sender:Tobject);
var i,j,pos:integer;
date:array [0..3,1..100] of string;
begin

pos:=Yc;

if (stringgrid1.RowCount-1)>Yc then
  begin                          {if}
for i:=0 to stringgrid1.ColCount-1 do {f1}
begin
for j:=Yc+1 to stringgrid1.RowCount-1 do
begin
date[i,j]:=stringgrid1.Cells[i,j]
end;
end;     {f1}

stringgrid1.RowCount:=stringgrid1.RowCount-1;


for i:=0 to stringgrid1.ColCount-1 do {f1}
begin
for j:=Yc to stringgrid1.RowCount-1 do
begin
stringgrid1.Cells[i,j]:=date[i,j+1];
end;
end;     {f1}
  end {if}
  else
begin stringgrid1.RowCount:=stringgrid1.RowCount-1; end;

end;

Procedure Tform1.Raschet(sender: Tobject);
var i:integer;
begin
for i:=1 to stringgrid1.RowCount do
begin
if (a[i].SMTR<>'') and (a[i].VSum<>'') then
begin
stringgrid1.Cells[2,i]:=inttostr(strtoint(a[i].VSum)-strtoint(a[i].SMTR))
end;
end;

end;

procedure TForm1.FormShow(Sender: TObject);
begin
Stringgrid1.Cells[0,0]:='Телефон абонента';
Stringgrid1.ColWidths[0]:=120;
{Stringgrid1.Cells[1,0]:='Сумма внесеная абонентом';
Stringgrid1.ColWidths[1]:=150; }
Stringgrid1.Cells[1,0]:='Cумма за МТР';
Stringgrid1.ColWidths[1]:=120;
Stringgrid1.Cells[2,0]:='Остаток';
Stringgrid1.ColWidths[2]:=120;
{LoadFile(Sender); }
Sagruska(Sender,2);
LoadNastroi(Sender);
MAinmenu1.Items[0].Visible:=false;
MAinmenu1.Items[1].Visible:=false;
MAinmenu1.Items[2].Visible:=false;
MAinmenu1.Items[3].Visible:=false;
Panel1.Visible:=true;
Panel1.Align:=alClient;


end;

procedure TForm1.StringGrid1DblClick(Sender: TObject);
var i,sw:integer;
begin
Stringgrid1.DragMode:=dmAutomatic;
  {Если номер абонента}
{IF Xc=0 then begin
MaskEdit1.Visible:=true;
sw:=0;
MaskEdit1.Text:=stringgrid1.Cells[Xc,Yc];
for i:=0 to Xc-1 do begin sw:=sw+stringgrid1.ColWidths[i]; end;

MaskEdit1.Left:=stringgrid1.Left+sw;
MaskEdit1.Top:=stringgrid1.Top+(Yc*25);
end
else
begin

SpinEdit1.Visible:=true;
sw:=0;
SpinEdit1.Text:=stringgrid1.Cells[Xc,Yc];
for i:=0 to Xc-1 do begin sw:=sw+stringgrid1.ColWidths[i]; end;

SpinEdit1.Left:=stringgrid1.Left+sw;
SpinEdit1.Top:=stringgrid1.Top+(Yc*25);

end;      }

end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
Xc:=Acol;
Yc:=ARow;
selsap:=Arow-1;
end;

procedure TForm1.SpinEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  var i,len:integer;
  begin
if Key=Vk_Return then
begin
Spinedit1.Visible:=false;
stringgrid1.Cells[Xc,Yc]:=Spinedit1.text;
end;


Raschet(Sender);
end;

procedure TForm1.Button6Click(Sender: TObject);

begin


{delete(sender); }

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin

SaveNastroi(Sender); {Сохранение настроек}

{SAvefale(Sender);  }
Zastavka.Close;
end;

procedure TForm1.MaskEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if Key=Vk_Return then
begin
MaskEdit1.Visible:=false;
stringgrid1.Cells[Xc,Yc]:=MaskEdit1.text;
end;
END;

procedure TForm1.ToolButton1Click(Sender: TObject);
begin
Editi.Caption:='Новый абонент';
Editi.ShowModal;
end;

procedure TForm1.N4Click(Sender: TObject);
begin
close;
end;

procedure TForm1.ToolButton3Click(Sender: TObject);
begin
DeleteSapis(Sender);
Sagruska(Sender,2);
end;

procedure TForm1.N3Click(Sender: TObject);
begin
Sagruska(Sender,1);
end;

procedure TForm1.N2Click(Sender: TObject);
begin
Save(Sender,1);
end;

procedure TForm1.Image1Click(Sender: TObject);
begin
MAinmenu1.Items[0].Visible:=true;
MAinmenu1.Items[1].Visible:=true;
MAinmenu1.Items[2].Visible:=true;
MAinmenu1.Items[3].Visible:=true;
Panel1.Visible:=false;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin

image1.Picture.LoadFromFile('image\button2A.jpg');
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image1.Picture.LoadFromFile('image\button29.jpg');
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image1.Picture.LoadFromFile('image\button28.jpg');
end;

procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image1.Picture.LoadFromFile('image\button28.jpg');
end;

procedure TForm1.ToolButton2Click(Sender: TObject);
begin
Editi.Caption:='Редактирование абонента';
Editi.ShowModal;
end;

procedure TForm1.ToolButton5Click(Sender: TObject);
begin
Dolg.ShowModal;
end;

procedure TForm1.ToolButton6Click(Sender: TObject);
begin
panel2.Visible:=true
end;

procedure TForm1.ToolButton10Click(Sender: TObject);
begin

Close;
end;

procedure TForm1.ToolButton11Click(Sender: TObject);
begin
Grafic.Show;
end;

procedure TForm1.Button5Click(Sender: TObject);
var i:integer;
begin
Panel2.Visible:=false;
Edit1.Text:='Введите номер';
Edit2.Text:='';
MaskEdit3.Text:='';
MaskEdit2.Text:='';
Edit5.Text:='';
{for i:=2 to 5 do
begin
(findcomponent(format('Edit'+'%d',[i])) as TEdit).Text:='';
end;  }

end;

procedure TForm1.Edit1Click(Sender: TObject);
begin
Edit1.Text:='';
end;

procedure TForm1.Image2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image2.Picture.LoadFromFile('image\button11.jpg');
end;

procedure TForm1.Image2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image2.Picture.LoadFromFile('image\button12.jpg');
end;

procedure TForm1.Image2MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image2.Picture.LoadFromFile('image\button13.jpg');
end;

procedure TForm1.Panel2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
Stringgrid1.DragMode:=dmManual;
image2.Picture.LoadFromFile('image\button13.jpg');
end;

procedure TForm1.Image2Click(Sender: TObject);
begin
Form1.PoiskSApis2(Sender,Edit1.Text);
end;

procedure TForm1.Image3MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image3.Picture.LoadFromFile('image\button23.jpg');
end;

procedure TForm1.Image3MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image3.Picture.LoadFromFile('image\button22.jpg');
end;

procedure TForm1.Image3MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image3.Picture.LoadFromFile('image\button24.jpg');
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
Stringgrid1.DragMode:=dmManual;
image3.Picture.LoadFromFile('image\button22.jpg');
image4.Picture.LoadFromFile('image\button25.jpg');
image5.Picture.LoadFromFile('image\button1C.jpg');
end;

procedure TForm1.Image4MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image4.Picture.LoadFromFile('image\button26.jpg');
end;

procedure TForm1.Image4MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image4.Picture.LoadFromFile('image\button25.jpg');
end;

procedure TForm1.Image4MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image4.Picture.LoadFromFile('image\button27.jpg');
end;

procedure TForm1.Image5MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
image5.Picture.LoadFromFile('image\button1D.jpg');
end;

procedure TForm1.Image5MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image5.Picture.LoadFromFile('image\button1C.jpg');
end;

procedure TForm1.Image5MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
image5.Picture.LoadFromFile('image\button1E.jpg');
end;

procedure TForm1.Image3Click(Sender: TObject);
begin
panel2.Visible:=true;
end;

procedure TForm1.Image4Click(Sender: TObject);
begin
Grafic.Show;
end;

procedure TForm1.Image5Click(Sender: TObject);
begin
Dolg.ShowModal;
end;

procedure TForm1.N25Click(Sender: TObject);
begin
Edit1.Text:=Stringgrid1.Cells[Xc,Yc];
panel2.Visible:=true;
Form1.PoiskSApis2(Sender,Edit1.Text);

end;

procedure TForm1.N8Click(Sender: TObject);
begin
DeleteSapis(Sender);
Sagruska(Sender,2);
end;

procedure TForm1.N23Click(Sender: TObject);
begin
Sagruska(Sender,2);
DeleteSapis(Sender);
Sagruska(Sender,2);
end;

procedure TForm1.N24Click(Sender: TObject);
begin
Editi.Caption:='Редактирование абонента';
Editi.ShowModal;
end;

procedure TForm1.N22Click(Sender: TObject);
begin
Editi.Caption:='Новый абонент';
Editi.ShowModal;
end;

procedure TForm1.N15Click(Sender: TObject);
begin
Save(Sender,1);
end;

procedure TForm1.N14Click(Sender: TObject);
begin
Sagruska(Sender,1);
end;

procedure TForm1.N6Click(Sender: TObject);
begin
Editi.Caption:='Новый абонент';
Editi.ShowModal;
end;

procedure TForm1.N7Click(Sender: TObject);
begin
Editi.Caption:='Редактирование абонента';
Editi.ShowModal;
end;

procedure TForm1.N19Click(Sender: TObject);
begin
DeleteSapis(Sender);
Sagruska(Sender,2);
end;

procedure TForm1.N18Click(Sender: TObject);
begin
Editi.Caption:='Редактирование абонента';
Editi.ShowModal
end;

procedure TForm1.N17Click(Sender: TObject);
begin
Editi.Caption:='Новый абонент';
Editi.ShowModal;
end;

procedure TForm1.N20Click(Sender: TObject);
begin
Dolg.ShowModal;
end;

procedure TForm1.N12Click(Sender: TObject);
begin
Dolg.ShowModal;
end;

procedure TForm1.N21Click(Sender: TObject);
begin
panel2.Visible:=true;
end;

procedure TForm1.N11Click(Sender: TObject);
begin
panel2.Visible:=true;
end;

procedure TForm1.N10Click(Sender: TObject);
begin
{WinExec('C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE Help\h1.doc',SW_SHOW);   }
WinExec('C:\Program Files\Windows NT\Accessories\wordpad.exe help\h.rtf',SW_SHOW);

end;

procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Source.ClassName='TStringGrid' then Accept:=True
                                  else Accept:=False;
end;

procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
Edit1.Text:=(Source As TStringGrid).Cells[Xc,Yc];
end;

procedure TForm1.StringGrid1Click(Sender: TObject);
begin
Stringgrid1.DragMode:=dmManual;
Label5.Caption:='Чтобы переместить выбраное значение сделайте двойной щелчок'
end;

procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
if Source.ClassName='TPanel' Then Accept:=true
                             else Accept:=false;
end;

procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
(Source As TPanel).Left:=x;
(Source As TPanel).Top:=y;
end;

procedure TForm1.N27Click(Sender: TObject);
begin
ColorDialog1.Execute;
Form1.Color:=ColorDialog1.Color;
Editi.Color:=ColorDialog1.Color;
Dolg.Color:=ColorDialog1.Color;
Grafic.Color:=ColorDialog1.Color;
panel3.Color:=ColorDialog1.Color;
panel4.Color:=ColorDialog1.Color;
panel5.Color:=ColorDialog1.Color;

end;

procedure TForm1.N28Click(Sender: TObject);
begin
 FontDialog1.Execute;
Form1.Font:=FontDialog1.Font;
Editi.Font:=FontDialog1.Font;
Dolg.Font:=FontDialog1.Font;
Grafic.Font:=FontDialog1.Font;

end;

end.
